<?php
namespace app\admin\model;
use think\Model;
use think\Request;
use think\Log;
use think\Exception;
use think\Db;

class Place extends Model
{

   public function placeInfo()
   {
       return $this->hasMany('placeInfo','place_id','id');
   }



   public function selectList()
   {
        $res= Db::name('place')->alias('p')
        ->join('place_pic pl',' p.id=pl.place_id')
        ->order('p.id desc')
        ->paginate('',false,page_param());
        return $res;
   }

   public function chooseImage()
   {
       $res2 = $this->selectList();
       $res = [];
       foreach ($res2 as $res){
            $res['area']['name'] = Db::name('city')->where(['upid'=>$res['area']])->select();
       }

       return $res;
   }

   public function selectArea($upid = 9, $level = 1)
   {
       $res = Db::view('city')->field('name')->where($upid)->select();
       return $res;

   }





}
